﻿using System.Collections.Generic;

namespace bowlingkata
{
    internal partial class Frame
    {
        private const int MAX_POINTS_PER_ROLL = 10;
        private const int MAX_ROLLS_PER_FRAME = 2;

        public List<int> _rolls = new List<int>();
        public int _score;


        public Frame(){}
        internal Frame(int roll0, int roll1, int score)
        {
            this.AddRoll(roll0);
            this.AddRoll(roll1);
            _score = score;
        }


        public void AddRoll(int roll)
        {
            _rolls.Add(roll);
        }

        public int this[int i]
        {
            get { return i < _rolls.Count ? _rolls[i] : 0; }
        }


        public void AddPoints(int points)
        {
            _score += points;
        }

        public int Score { get { return _score; } }


        public bool IsSpare
        {
            get { return !this.IsStrike && (this[0] + this[1]) == MAX_POINTS_PER_ROLL; }
        }

        public bool IsStrike
        {
            get { return this[0] == MAX_POINTS_PER_ROLL; }
        }

        public bool IsFull
        {
            get { return this.IsStrike || _rolls.Count == MAX_ROLLS_PER_FRAME; }
        }
    }
}